package com.schoolCommunity.controller;


import com.schoolCommunity.entity.ConfessionWall;
import com.schoolCommunity.entity.Information;
import com.schoolCommunity.service.ConfessionWallService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-09-09
 */
@CrossOrigin
@RestController
public class ConfessionWallController {

    @Autowired
    private ConfessionWallService ConfessionWallService;

    //用户添加表白墙

    /**
     * 需要写入的有：
     * 用户ID，主题，内容，时间，昵称，
     */
    @PostMapping("/InsertConfession")
    public Information InsertConfession(@RequestBody ConfessionWall ConfessionWall) {
        return ConfessionWallService.InsertConfessionWall(ConfessionWall);
    }

    //删除表白墙，同时删除该表白墙下面的留言，管理员功能？
    @GetMapping("/DeleteConfessionWall/{id}")
    public Information DeleteConfessionWall(@PathVariable long id) {
        return ConfessionWallService.deleteConfessionWall(id);
    }

    //获取所有表白墙，管理者端
    @PostMapping("/getAllConfessionWallForAdmin")
    public Information getAllConfessionWallForAdmin() {
        return ConfessionWallService.getAllConfessionWallForAdmin();
    }

    //获取所有未通过审核的表白墙，管理者端
    @PostMapping("/getNotPassConfessionWall")
    public Information getNotPassConfessionWall() {
        return ConfessionWallService.getNotPassConfessionWall();
    }

    //获取所有尚未审核的表白墙
    @PostMapping("/getNotSuggestConfessionWall")
    public Information getNotSuggestConfessionWall() {
        return ConfessionWallService.getNotSuggestConfessionWall();
    }

    //管理员审核表白墙
    @GetMapping("/AdminSuggestConfessionWall/{ConfessionWallId}/{suggestResult}")
    public Information AdminSuggestConfessionWall(@PathVariable("ConfessionWallId") long ConfessionWallId, @PathVariable("suggestResult") int suggestResult) {
        return ConfessionWallService.AdminSuggestConfessionWall(ConfessionWallId, suggestResult);
    }

    //管理员审核表白墙后发布通过的表白墙。
    @PostMapping("/AdminPublishConfessionWall")
    public Information AdminPublishConfessionWall(@RequestBody int[] pushList) {
        System.out.println(pushList);
        return ConfessionWallService.AdminPublishConfessionWall(pushList);

    }


    //获取所有表白墙，普通用户端
    @PostMapping("/getAllConfessionWall")
    public Information getAllConfessionWall() {
        return ConfessionWallService.getAllConfessionWall();
    }

    //获取指定期数的表白墙
    @GetMapping("/getAppointConfessionWall/{periods}")
    public Information getAppointConfessionWall(@PathVariable("periods") int periods) {
        return ConfessionWallService.getPeriodsConfessionWall(periods);
    }

    //获取指定用户的表白墙
    @PostMapping("/getMemberConfessionWall/{memberId}")
    public Information getMemberConfessionWall(@PathVariable("memberId") long memberId) {
        return ConfessionWallService.getMemberConfessionWall(memberId);
    }


    //获取最大的期数
    @GetMapping("/getMaxPeriods")
    public int getMaxPeriods() {
        return ConfessionWallService.getMaxPeriods();
    }

    //表白墙点赞
    @GetMapping("/AddLoves/{confessionWallId}/{memberId}")
    public Information AddLoves(@PathVariable("confessionWallId") long confessionWallId,
                                @PathVariable("memberId") long memberId) {
        return ConfessionWallService.AddLoves(confessionWallId, memberId);
    }


}

